package cn.jhs.config.security.plugins;

import cn.jhs.config.security.sys.SysmangerService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

/**
 * @author Trump
 * @version 1.0.0
 * @ClassName SimpleUserDetailsServiceImpl.java
 * @Description TODO
 * @createTime 2019年08月15日 15:25:00
 */
public class SimpleUserDetailsServiceImpl implements UserDetailsService {
    protected Log logger = LogFactory.getLog(getClass());
    @Autowired
    private SysmangerService sysmangerService;
    @Override
    public UserDetails loadUserByUsername(String loginAcct) throws UsernameNotFoundException {
        try{
            return sysmangerService.loadUserDetailsByLoginAcct(loginAcct);
        }catch (Exception e){
            logger.error(e.getMessage());
            throw new UsernameNotFoundException("未找到输入信息对应对用户：" + e.getMessage());
        }
    }
}
